package RTL.Task3;

//流量套餐封装
public class NetPackageServiceImpl extends Package implements NetService {
    private double netFlow;

    // 调用set方法判断
    public NetPackageServiceImpl() {
    }
    public NetPackageServiceImpl(double rate, double netFlow) {
        super(rate);
        setNetFlow(netFlow);
    }

    // get和set并进行判断
    public double getNetFlow() {
        return netFlow;
    }

    public void setNetFlow(double netFlow) {
        if (netFlow >= 0) {
            this.netFlow = netFlow;
        } else {
            System.out.println("网络流量不合法，请重新输入");
        }
    }

    // 4.显示套餐信息
    @Override
    public void show() {
        System.out.println("上网流量为: " + getNetFlow() + "MB， 月费为: " + getRate() + "元");
    }

    @Override
    public void net(double netFlow, PhoneCard phoneCard) {
        System.out.println("流量信息");
    }
}
